package org.atlantis.grosbeak.pot;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class GenerateDatabase {
	
	private static String table = "DROP TABLE IF EXISTS USERS;" +
			"CREATE TABLE USERS(" +
			"USER_ID INTEGER IDENTITY PRIMARY KEY," +
			"USER_NAME VARCHAR(10) NOT NULL," +
			"USER_GENDER BOOLEAN DEFAULT FALSE," +
			"USER_AGE INTEGER);";
	
	public static void createDatabase() throws Exception {
		Class.forName("org.hsqldb.jdbcDriver");
		Connection con = DriverManager.getConnection(
				"jdbc:hsqldb:file:dbs/grosbeak.db", "sa", "");
		Statement stat = con.createStatement();
		stat.executeUpdate(table);
		stat.execute("SHUTDOWN");
		stat.close();
		con.close();
	}
	
	public static void main(String[] args) throws Exception {
		createDatabase();
	}
}
